package com.ws.system.user.service.impl;

import cn.hutool.core.util.PageUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ws.common.result.entity.ResultEntity;
import com.ws.common.utils.PageUtils;
import com.ws.system.user.entity.SystemUser;
import com.ws.system.user.mapper.SystemUserMapper;
import com.ws.system.user.service.ISystemUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author weifucheng
 * @since 2019-10-26
 */
@Service
public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemUser> implements ISystemUserService {

    @Override
    public Page<SystemUser> list(SystemUser user, Integer current, Integer size) {
        Page<SystemUser> page= PageUtils.newPage(current, size);
        page.setRecords(baseMapper.listByParam(page,user));
        return page;
    }

    @Override
    public SystemUser readByUserName(String userName) {
        SystemUser user=new SystemUser();
        user.setUserName(userName);
        Page<SystemUser> page=this.list(user,1,1);
        if(page.getRecords().size()==0){
            return null;
        }
        return page.getRecords().get(0);
    }
}
